<?php include('head.php')?>

<style type="text/css">
.mainbody{background: url(common/background.gif) repeat;}
.mdiv{
width: 960px;
height: 700px;
padding-bottom: 50px;
}
.left{
width: 480px;
height: 350px;
vertical-align: top;
}
.right{width: 480px;vertical-align: top;padding-top: 5px;}
.right>div{
margin-left: 45px;
line-height: 19px;
font-weight: bold;
position: relative;
text-align: left;
width: 435px;
}
.left_td,.left_td2{
text-align: right;
font-weight: bold;
padding: 5px 15px;
white-space: nowrap;
font-size: 15px;
}
.left_td2{vertical-align: top;padding-top: 5px;}
.left table div{float: right;height: 95px;padding-top: 5px;}
input,textarea{border: solid 1px #b7b7b7;background-color:transparent;margin-right: 5px;}
textarea{width: 300px; height: 125px;}
.intd{width: 305px;}
.send{text-align: right; padding: 20px 8px 20px 0;}

.mdiv img{cursor: pointer;}
.titler{
color: #0c4252!important;
border-top: solid 1px #b7b7b7;
margin-top: 5px;
padding: 5px 0 2px;
font-size: 15px;
}
.branch1,.branch2,.branch3{
font-weight: bold;
padding-bottom: 5px;
}
.branch1{width: 80px;}
.branch2{width: 100px;}
.branch3{width: 57px;}
#message_input{margin-top: 4px;}
#name,#number,#email,#venue,#date{height: 21px;width: 300px;}
#sys_map,#mel_map,#bri_map{position: absolute;right: 1px;;bottom: 4px;}
#send{width: 130px;height: 26px;background:url(common/send.png) no-repeat;cursor: pointer;border: none;}
#remind,#success{padding-left: 160px;white-space: nowrap;color: #ff0000;font-weight: bold;font-size: 15px;font-style: italic;display: none;}
#remind span{font-size: 18px;}
#branch{margin-left: 160px;}
</style>
<script lanuage="javascript">
function checkpost(){
  var remind = document.getElementById('remind');
  var branch = document.getElementById('branch');
  var parms = document.getElementsByName('studio');
  var success = document.getElementById('success');
  success.style.display = 'none';
  var num=0;
  for (var i=0; i<parms.length; i++){
    if(parms[i].checked) {
      num++;
    }
  }
  if(num==0){
    branch.style.border = 'solid 2px #ff0000';
    remind.style.display = 'inline';
    return false;
  }
  if(document.myform.name.value == "" || document.myform.phone.value == "" || document.myform.email.value == "" || document.myform.message.value == ""){
    remind.style.display = 'inline';
    return false;
  }
}
$(document).ready(function(){
  $("#branch").click(function(){
    $(this).css("border","none");
  });
});
</script>
</head>

<body class="mainbody">
  <table cellpadding=0 cellspacing=0>
    <tr>
      <td id="title"><div><img src="common/logo_contact.png" /></div></td>
      <td class="mdiv" valign="middle" align="left">
        <table class="cdiv">
          <tr>
          <td class="left" align="left">
            <form action="" name="myform" method="post" onSubmit="return checkpost()">
            <table id="branch">
              <tr>
              <td><input type="radio" name="studio" value="sydney" onfocus = this.blur() /></td>
              <td class="branch1">Sydney</td>
              <td><input type="radio" name="studio" value="melbourne" onfocus = this.blur() /></td>
              <td class="branch2">Melbourne</td>
              <td><input type="radio" name="studio" value="brisbane" onfocus = this.blur() /></td>
              <td class="branch3">Brisbane</td>
              </tr>
            </table>
            <table style="width: 480px;">
              <tr>
                <td class="left_td">Name</td>
                <td class="intd"><input id="name" name="name"></input></td>
                <td>*</td>
              </tr>
              <tr>
                <td class="left_td">Contact Number</td>
                <td class="intd"><input id="number" name="phone"></input></td>
                <td>*</td>
              </tr>
              <tr>
                <td class="left_td">Email</td>
                <td class="intd"><input id="email" name="email"></input></td>
                <td>*</td>
              </tr>
              <tr>
                <td class="left_td">Preferred Date</td>
                <td class="intd"><input id="date" name="date" value="DD/MM/YYYY"></input></td>
              </tr>
              <tr>
                <td class="left_td2">Message</td>
                <td class="intd"><textarea id="message_input" name="message"></textarea></td>
                <td valign="top" style="padding-top: 7px">*</td>
              </tr>
              <tr>
                <td></td>
                <td colspan=6 class="send"><input id="send" type="Submit" value=""></img></td>
              </tr>
            </table>
            </form>
          </td>
          <td class="right">
            <div class="titler">Sydney Studio</div>
            <div>(02) 9518 6866</div>
            <div>313 Abercrombie St, Darlington, NSW 2008</div>
            <div>11:00AM~6:00PM  Open 6 days; Tuesdays closed.<a href="http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=313+Abercrombie+St,Darlington,NSW,2008&sll=-25.335448,135.745076&sspn=40.169951,79.013672&ie=UTF8&hq=&hnear=313+Abercrombie+St,+Darlington+New+South+Wales+2008&z=16" target="_blank"><img src="common/google_map.jpg" id="sys_map"></img></a></div>
            <div class="titler">Melbourne Studio</div>
            <div>(03) 9663 1880</div>
            <div>357 Exhibition St, Melbourne CBD, VIC 3000</div>
            <div>11:00AM~6:00PM  Open 6 days; Tuesdays closed.<a href="http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=357+Exhibition+Street,+Melbourne&aq=&sll=-37.799442,144.996743&sspn=0.026721,0.066047&ie=UTF8&hq=&hnear=357+Exhibition+St,+Melbourne+Victoria+3000&ll=-37.807546,144.968376&spn=0.006891,0.016512&z=17" target="_blank"><img src="common/google_map.jpg" id="mel_map"></img></a></div>
            <div class="titler">Brisbane Studio</div>
            <div>(07) 3666 0886</div>
            <div>9 Byres St, Newstead, QLD 4006</div>
            <div>10:00AM-8:PM Open 6 days; Tuesdays closed.<a href="http://maps.google.com.au/maps?f=q&source=s_q&hl=en&geocode=&q=9+Byres+Street,+Newstead,+Queensland&sll=-25.335448,135.745076&sspn=35.914498,86.572266&ie=UTF8&hq=&hnear=9+Byres+St,+Newstead+Queensland+4006&z=16" target="_blank"><img src="common/google_map.jpg" id="bri_map"></img></a></div>
            <div class="titler"></div>
          </td>
          </tr>
        </table>
        <div id="remind">
          Please kindly complete the fields marked with <span>* </span>.
        </div>
	      <div id="success">
	        Thank you for your message! We will be in contact with you shortly.
	      </div>
	      </td>
      <td id="right">&nbsp;</td>
    </tr>
  </table>
  <div align="center">
    <?php include('menu.php')?>
  </div>
  <script lanuage="javascript">
  var date = document.getElementById('date');
  date.onfocus = function() { if(date.value == 'DD/MM/YYYY'){
                                date.value='';
                              }
                            }
  date.onblur = function() { if (date.value == '') {
                               date.value = 'DD/MM/YYYY';
  }}
  </script>
</body>
</html>

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $studio=$_POST['studio'];
  $name=$_POST['name'];
  $phone=$_POST['phone'];
  $email=$_POST['email'];
  $date=$_POST['date'];
  $msg = $_POST['message'];

  $message = "Name: " . $name . "\n" . "\n".
             "Contact number: " . $phone . "\n" . "\n" .
             "Email Address: " . $email . "\n" . "\n" .
             "Wedding Date: " . $date . "\n" . "\n" .
             "Enquiry Detail: " . "\n" . $msg;
    
  if($studio=='sydney'){
    $to='sydney@dreamlife.net.au';
  }
  if($studio=='melbourne'){
    $to='melbourne@dreamlife.net.au';
  }
  if($studio=='brisbane'){
    $to='brisbane@dreamlife.net.au';
  }

  //$_SESSION["to"]=$to;
  //$to='kissrain8@qq.com';
  
  $header="From:".$name."<".$email.">";
  if (eregi("\r",$name) || eregi("\n",$name) || eregi("\r",$name) || eregi("\n",$name)){
       //die("Error occures :(!");
     }
  if($name!='' || $phone!=''){   
    mail($to,'Dreamlife Enquiry',$message,$header);
  //mail('marco@plateau.co.nz','Dreamlife Enquiry'.$studio,$message,$header);
    echo "<script>location.href='thanks.php'</script>";
  }
}
?>